<?php
/**
 * Created by PhpStorm.
 * User: 聪
 * Date: 2019/4/18
 * Time: 13:48
 */

namespace applets;


use curl\HttpRequest;

class User extends Applets
{
    protected $session_url = 'https://api.weixin.qq.com/sns/jscode2session';

    public function get_session(string $jsCode)
    {
        $data = [
            'js_code'    => $jsCode,
            'appid'      => static::APPID,
            'secret'     => static::SECRET,
            'grant_type' => 'authorization_code'
        ];
        HttpRequest::$url = $this->session_url;
        HttpRequest::$data = $data;
        return json_decode(HttpRequest::request()[$this->session_url],true);
    }

}
